/*
 * > /*
>  * INSANE - Interactive Structural Analysis Environment
>  *
>  * Copyright (C) 2003-2004
>  * Universidade Federal de Minas Gerais
>  * Escola de Engenharia
>  * Departamento de Engenharia de Estruturas
>  *
>  * Author's email :     insane@dees.ufmg.br
>  * Author's Website :   http://www.dees.ufmg.br/insane
>  *
>  * This program is free software; you can redistribute it and/or
>  * modify it under the terms of the GNU General Public License
>  * as published by the Free Software Foundation; either version 2
>  * of the License, or any later version.
>  *
>  * This program is distributed in the hope that it will be useful,
>  * but WITHOUT ANY WARRANTY; without even the implied warranty of
>  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>  * GNU General Public License for more details.
>  *
>  * You should have received a copy of the GNU General Public License
>  * along with this program; if not, write to the Free Software
>  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-
> 1307, USA.
 *
 */

package br.ufmg.dees.insane.ui.rich.postp.postp_view.dialog;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.Image;
import java.awt.Toolkit;

import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;

import br.ufmg.dees.insane.ui.rich.postp.postp_view.DesktopPostp;
import br.ufmg.dees.insane.ui.rich.postp.postp_view.LoadingSplashScreen;

/**
 * A class representing creation dialog on screen.<br>
 *
 * @author Fonseca, Flavio & Pitangueira, Roque
 * @see gui.Interface
 * @since July 2004
 */
public final class LoadingDialog extends JFrame {

    /**
	 * Comment for <code>serialVersionUID</code>
	 */
	private static final long serialVersionUID = 1L;
    private LoadingSplashScreen loadBar;
    private JTextArea textArea;
	private JScrollPane scrollPane;
	
//*****************************************************************************
	
    public LoadingDialog(DesktopPostp parent) {
    	Image ico = Toolkit.getDefaultToolkit().getImage(ClassLoader.getSystemResource("br/ufmg/dees/insane/images/Insane64.gif"));
		this.setIconImage(ico);
    	//this.parent = parent;
    	this.setTitle("Loading...");
    	this.setSize(new Dimension(300,300));
    	this.setLocation(200,200);
    	this.setResizable(false);
    	this.setAlwaysOnTop(true);
        LoadingSplashScreen.setDesktop(parent);
        loadBar = LoadingSplashScreen.getInstance();
        loadBar.openSplash();
    	
//    	Sets the colors panel
        JPanel mainPane = new JPanel();
        mainPane.setLayout(new GridLayout(1,3,2,2));
        mainPane.setBorder(BorderFactory.createCompoundBorder(
        BorderFactory.createTitledBorder(""),
        BorderFactory.createEmptyBorder(2,2,2,2)));
        mainPane.setMaximumSize(new Dimension(500,300));
        
        JPanel textPane = new JPanel();
        textPane.setLayout(new GridLayout(1,1,1,1));          
        textPane.setMaximumSize(new Dimension(500,245));
        textPane.setBorder(BorderFactory.createCompoundBorder(
        BorderFactory.createTitledBorder("Files Loaded"),
        BorderFactory.createEmptyBorder(3,3,2,2)));
        
        this.textArea = new JTextArea();
        this.textArea.setBackground(Color.BLACK);
	    this.textArea.setForeground(Color.GREEN);
	    this.textArea.setAutoscrolls(true); 
        this.scrollPane = new JScrollPane(textArea);
        scrollPane.setAutoscrolls(true);
        this.scrollPane.setViewportView(this.textArea); 
        textPane.add(scrollPane, BorderLayout.CENTER);
        
        JPanel barPane = new JPanel();
        barPane.setLayout(new GridLayout(1,1,2,2));          
        barPane.setSize(new Dimension(500,55));
        barPane.setBorder(BorderFactory.createCompoundBorder(
        BorderFactory.createTitledBorder("Bar Progress"),
        BorderFactory.createEmptyBorder(2,2,2,2)));
        
        barPane.setMaximumSize(new Dimension(500,55));
        barPane.add(loadBar);
    	
        //Sets general panel
        JPanel generalPane = new JPanel();
        generalPane.setLayout(new BoxLayout(generalPane, BoxLayout.Y_AXIS));
        generalPane.add(barPane);
        generalPane.add(textPane);
    	
    	this.add(generalPane);
        
    }
//*****************************************************************************
	
    /**
     * This method is executed on OK button click.
     *
     */
    public void approvedPerform() {
        try {
			
			
        } catch (Exception err) {
            Toolkit.getDefaultToolkit().beep();
            this.setVisible(false);
        }
    }
    
//*****************************************************************************
	
	/**
	 * The method return the scrollPane.
	 * @return Returns The scrollPane.
	 */
	public JScrollPane getScrollPane() {
		return scrollPane;
	}

	/**
	 * The method set the field scrollPane from the parameter scrollPane.
	 * @param scrollPane The scrollPane to set.
	 */
	public void setScrollPane(JScrollPane scrollPane) {
		this.scrollPane = scrollPane;
	}

	/**
	 * The method return the textArea.
	 * @return Returns The textArea.
	 */
	public JTextArea getTextArea() {
		return textArea;
	}

	/**
	 * The method set the field textArea from the parameter textArea.
	 * @param textArea The textArea to set.
	 */
	public void setTextArea(JTextArea textArea) {
		this.textArea = textArea;
	}

	/**
	 * The method return the loadBar.
	 * @return Returns The loadBar.
	 */
	public LoadingSplashScreen getLoadBar() {
		return loadBar;
	}

	/**
	 * The method set the field loadBar from the parameter loadBar.
	 * @param loadBar The loadBar to set.
	 */
	public void setLoadBar(LoadingSplashScreen loadBar) {
		this.loadBar = loadBar;
	}
	
//*****************************************************************************
}
